package org.annoflow.filter.auth;

import org.annoflow.audit.Logger;
import org.annoflow.filter.FilterPoint;

public class LoginStatusFilter implements FilterPoint {

	@Override
	public String getFilterCode() {
		return null;
		//return "org.annoflow.filter.auth.LoginStatusFilter.logFail($0,$$);";
	}
	public static void logFail(Object o,String message)
	{
		Logger.error(LoginStatusFilter.class.getName(), o.getClass(), o, message);
	}
	@Override
	public String getReturnFilterCode() {
		return "$_ = ($r)org.annoflow.filter.auth.LoginStatusFilter.logFailure($0, $_);";
	}
	
	public static Object logFailure(Object owner, boolean val) {
//		if (val instanceof Boolean) {
			if (!((Boolean)val).booleanValue()) {
				Logger.error(
						LoginStatusFilter.class.getName(), owner.getClass(), owner, "Failed login");
			}
//		}
		return val;
	}

}
